package com.bjesc_b2c.app.appraiset.adapter;

import android.content.Context;
import android.text.TextUtils;

import com.bjesc_b2c.app.appraiset.R;

import java.util.List;

import app.pinggushi.bjesc.com.baserecyclerview.adapter.CommonAdapter;
import app.pinggushi.bjesc.com.baserecyclerview.adapter.base.ViewHolder;
import master_bean.CarForBean;

/**
 * Created by Jason Chen on 2017/2/22.
 */

public class CarfromTwoAdapter extends CommonAdapter<CarForBean> {
    public static int TYPE_ONE  = 1;
    public static int TYPE_TWO  = 2;
    public static int TYPE_THREE  = 3;
    public static int TYPE_FOURE  = 4;
    private int type;
    public CarfromTwoAdapter(Context context, int layoutId, List<CarForBean> datas , int type) {
        super(context, layoutId, datas);
        this.type = type;
    }
    @Override
    protected void convertView(ViewHolder holder, CarForBean bean, int position) {
       if (type == TYPE_ONE){
           holder.setText(R.id.tv_dealer_name, bean.getName());
           if (TextUtils.isEmpty(bean.getAddress())){
               holder.setVisible(R.id.tv_dealer_address,false);
           }else {
               holder.setText(R.id.tv_dealer_address, bean.getAddress());
           }
           if (TextUtils.isEmpty(bean.getBoss()) && TextUtils.isEmpty(bean.getPhone()) ){
               holder.setVisible(R.id.tv_name_phone,false);
           }else {
               holder.setText(R.id.tv_name_phone, bean.getBoss() +" "+bean.getPhone());
           }
           if (TextUtils.isEmpty(bean.getInventory_time())){
               holder.setVisible(R.id.tv_check_type,false);
           }else {
               holder.setVisible(R.id.tv_check_type,true);
//             1，今日已盘库；2，盘库时间：2017-02-32；3，超期未盘库；4，未盘库
               if (bean.getType() ==1){
                   holder.setTextColorRes(R.id.tv_check_type,R.color.color35B247);
               }else if(bean.getType() ==2){
                   holder.setTextColorRes(R.id.tv_check_type,R.color.colorFF28AFE1);
               }else {
                   holder.setTextColorRes(R.id.tv_check_type,R.color.colorFFF7041B);
               }
               holder.setText(R.id.tv_check_type, bean.getInventory_time());
           }

       }else if(type ==TYPE_TWO){
           holder.setText(R.id.tv_carfrom_two,bean.getMarket_name());
       }else if(type ==TYPE_THREE){
           holder.setText(R.id.tv_dealer_name, bean.getName());
           if (TextUtils.isEmpty(bean.getAddress())){
               holder.setVisible(R.id.tv_dealer_address,false);
           }else {
               holder.setText(R.id.tv_dealer_address, bean.getAddress());
           }
           if (TextUtils.isEmpty(bean.getBoss()) && TextUtils.isEmpty(bean.getPhone()) ){
               holder.setVisible(R.id.tv_name_phone,false);
           }else {
               holder.setText(R.id.tv_name_phone, bean.getBoss() +" "+bean.getPhone());
           }
           holder.setVisible(R.id.tv_check_type,false);
       }else if(type ==TYPE_FOURE){
           holder.setText(R.id.tv_carfrom_two,bean.getName());
       }
    }

}
